﻿using System;

namespace YArchitech.Plumbing
{
	public class UsedWaterCalculate
	{
		public UsedWaterCalculate(WaterCalculateType type, string name)
		{
			this.calculateType = type;
			this.typeName = name;
			this.maxUsedProposal = 0.0;
			this.maxUsedRange = "";
			this.coefficientProposal = 0.0;
			this.coefficientRange = "";
			this.unit = "";
			this.usedTime = "";
			this.usedTimeProposal = 0.0;
			this.usedCount = 1.0;
			this.maxUsedPerDay = 0.0;
			this.maxUsedPerHour = 0.0;
			this.aveUserPerHour = 0.0;
		}

		public UsedWaterCalculate(UsedWaterCalculate obj)
		{
			this.calculateType = obj.calculateType;
			this.typeName = obj.typeName;
			this.maxUsedProposal = obj.maxUsedProposal;
			this.maxUsedRange = obj.maxUsedRange;
			this.coefficientProposal = obj.coefficientProposal;
			this.coefficientRange = obj.coefficientRange;
			this.unit = obj.unit;
			this.usedTime = obj.usedTime;
			this.usedTimeProposal = obj.usedTimeProposal;
			this.usedCount = obj.usedCount;
			this.maxUsedPerDay = obj.maxUsedPerDay;
			this.maxUsedPerHour = obj.maxUsedPerHour;
			this.aveUserPerHour = obj.aveUserPerHour;
		}

		public virtual WaterCalculateType calculateType { get; set; }

		public virtual string typeName { get; set; }

		public virtual double maxUsedProposal { get; set; }

		public virtual string maxUsedRange { get; set; }

		public virtual double coefficientProposal { get; set; }

		public virtual string coefficientRange { get; set; }

		public virtual string unit { get; set; }

		public virtual string usedTime { get; set; }

		public virtual double usedTimeProposal { get; set; }

		public virtual double usedCount { get; set; }

		public virtual double maxUsedPerDay { get; set; }

		public virtual double maxUsedPerHour { get; set; }

		public virtual double aveUserPerHour { get; set; }

		public virtual bool Calculate()
		{
			bool result = false;
			try
			{
				this.maxUsedPerDay = this.maxUsedProposal * this.usedCount / 1000.0;
				if (this.usedTimeProposal != 0.0)
				{
					this.aveUserPerHour = this.maxUsedPerDay / this.usedTimeProposal;
					this.maxUsedPerHour = this.aveUserPerHour * this.coefficientProposal;
					result = true;
				}
			}
			catch (Exception ex)
			{
				ex.ToString();
			}
			return result;
		}
	}
}
